import 'dart:convert';

import 'package:flutter/material.dart';
import 'package:qr_flutter/qr_flutter.dart';
import 'package:xiongan_app_yy/widgets/zoomble_widget.dart';

class ImageDetails extends StatelessWidget {
  dynamic data;

  ImageDetails(this.data);

  @override
  Widget build(BuildContext context) {
    return Container(
        child: data["code"]
            ? Center(
                child: Container(
                  color: Colors.white,
                  padding: EdgeInsets.all(12),
                  width: double.infinity,
                  child: QrImage(
                    data: data["data"],
                    version: QrVersions.auto,
                  ),
                ),
              )
            : Stack(
                children: <Widget>[
                  Center(
                    child: Container(
                      width: double.infinity,
                      child: ZoomableImage(
                        data["data"] == "assets/images/build.png"
                            ? AssetImage(data["data"])
                            : MemoryImage(base64Decode(data["data"])),
                        maxScale: 1.6,
                        minScale: 0.2,
                      ),
                    ),
                  ),
                  Positioned(
                    child: Visibility(
                      child: GestureDetector(
                        onTap: () {
                          Navigator.pop(context);
                        },
                        child: Container(
                          child: Image.asset("assets/images/icon_close.png"),
                          width: 36,
                          height: 36,
                        ),
                      ),
                      visible: data["data"] != "assets/images/build.png",
                    ),
                    right: 12,
                    top: 16,
                  )
                ],
              ));
  }
}
